<template>
  <div class="wrapper" ref="wrapper">
      <div class="content">
          <slot></slot>
      </div>
  </div>
</template>

<script>
import BScroll from 'better-scroll'
export default {
  name: 'Scroll',
  data () {
   return {
       scroll: null,
       position: [],
   }
  },
  methods:{
      //返回
      scrollTo(x,y,time=300){
          this.scroll.scrollTo(x,y,time);
      },
      //刷新数据
    finishPullUp(){
      this.scroll && this.scroll.finishPullUp();
    }
  },
  mounted() {
      this.scroll=new BScroll(this.$refs.wrapper,{//使用ref可以拿到DOM对象
         click: true,
         tap: true,
         scroll: true,
         observeDOM: true,
         probeType: this.probeType,
         pullUpLoad: this.pullUpLoad,
         observeImage: true,
      })

      this.scroll.on("scroll",(position) => {
         this.$emit('scroll', position);
      })
      //重新计算滚动高度
     
      //监听上拉事件
      
      this.scroll.on("pullingUp",() => {
          this.$emit('pullingUp');
      })

      

      
     



      
  },
  props: {
      probeType: {
          type: Number,
          default(){
              return 0;
          }
      },

      pullUpLoad: {
          type: Boolean,
          default(){
              return false;
          }
      }
  },
//   destroyed() {
//       this.scroll=null;
//   },
}
</script>

<style scoped>
  
</style>